﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace coliseu.BussinessLayer
{
    public class ReservaBL
    {
         private coliseuEntities cEntities;

         public ReservaBL()
        {
            cEntities = new coliseuEntities(Properties.Settings.Default.conn_coliseu);
        }

        public List<reserva> selecionar()
        {
            return (from x in cEntities.reserva select x).ToList();
        }

        public List<reserva> selecionar(DateTime dti, DateTime dtf)
        {
            return (from x in cEntities.reserva where x.data_utilizacao >= dti && x.data_utilizacao <= dtf select x).ToList();
        }

        public void salvar(reserva b, string tipo)
        {

            if (tipo == "insert")
            {
                cEntities.AddToreserva(b);
            }
            else
            {
                cEntities.reserva.ApplyCurrentValues(b);
            }
            cEntities.SaveChanges();
        }

        public void excluir(reserva b)
        {
            cEntities.reserva.DeleteObject(b);
            cEntities.SaveChanges();
        }
    }
}
